<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;
    }

    .doctor_info {
        margin: 1rem 0;
        height: 2.5rem;
        position: relative;
    }

    .doctor_info .user_avater {
        width: 2.5rem;
        height: 2.5rem;
        position: absolute;
        left: 1rem;
        top: 0rem;
        border-radius: 1.25rem;
    }

    .doctor_info .doctor_name {
        position: absolute;
        top: 0.25rem;
        left: 4.5rem;
        font-size: 0.7rem;
        color: #303030;
    }

    .doctor_info .doctor_post {
        position: absolute;
        bottom: 0.25rem;
        left: 4.5rem;
        font-size: 0.6rem;
        color: #838383;
    }

    .doctor_info .edit {
        height: 1.2rem;
        width: 1.2rem;
        position: absolute;
        right: 1rem;
        top: 0.6rem;
    }

    .doctor_info_detail {
        padding: 0 1rem;
    }

    .doctor_info_detail div {
        width: 100%;
        font-size: 0.6rem;
        color: #838383;
        border-bottom: 1px dashed #E8E8E8;
    }

    .doctor_info_detail div p {
        margin-bottom: 1rem;
    }

    .doctor_info_detail div p span:nth-child(1) {
        width: 3rem;
    }

    .doctor_info_detail div p span:nth-child(2) {
        color: #565656;
        margin-left: 0.5rem;
    }

    .jianli {
        padding: 1rem;
        border-bottom: 1px dashed #E8E8E8;
    }

    .jianli:last-child {
        border: none;
    }

    .jianli div {
        width: 100%;
    }

    .jianli div .jianli_title {
        color: #565656;
        font-size: 0.7rem;
    }

    .jianli div .jianli_title span {
        font-size: 0.6rem;
        float: right;
    }

    .jianli .add_jianli {
        width: 80%;
        margin-left: 10%;
        height: 2.2rem;
        text-align: center;
        line-height: 2.2rem;
        border: 1px solid #E8E8E8;
        border-radius: 0.5rem;
        color: #565656;
        font-size: 0.8rem;
        margin-top: 1rem;
    }

    textarea {
        width: 100%;
        padding: 0.5rem 0;
        font-size: 0.6rem;
    }

    .edit_icon {
        position: absolute;
        top: 0rem;
        right: .8rem;
        width: 1rem;
        height: 1rem;
    }
</style>

<body>
    <div id="app" v-cloak>
        <div class="placeholder_div"></div>

        <div class="doctor_info">
            <img class="user_avater" :src="avatar" v-if="avatar" alt="">
            <img class="user_avater" src="../image/user_avater.png" v-else alt="">
            <p class="doctor_name">{{info.name}}</p>
            <p class="doctor_post">{{info.jobtitle}}</p>
            <img src="../image/icon_edit.png" onclick="go_edit()" class="edit_icon" alt="">
        </div>

        <div class="doctor_info_detail">
            <div>
                <p><span>性 别</span><span v-if="info.sex == 1">男</span><span v-else-if="info.sex == 2">女</span><span
                        v-else>未知</span></p>
                <!-- <p><span>地 区</span><span v-if="info.address">{{info.address}}</span><span v-else>未知</span></p> -->
                <p><span>医疗机构</span><span v-if="info.hospital">{{info.hospital}}</span><span v-else>未知</span></p>
                <p><span>科 室</span><span v-if="info.department">{{info.department}}</span><span v-else>未知</span></p>
            </div>
        </div>

        <div class="jianli">
            <div>
                <p class="jianli_title">
                    简介 <span>完善个人介绍，能让患者更信任您哦</span>
                </p>
                <textarea readonly v-model="info.brief" v-if="info.brief"></textarea>
                <div v-else class="add_jianli" onclick="go_edit()">该医生暂未添加个人简介</div>
            </div>
        </div>

        <div class="jianli">
            <div>
                <p class="jianli_title">
                    擅长 <span>添加专业领域，擅长让患者更快了解您</span>
                </p>
                <textarea readonly v-model="info.specially" v-if="info.specially"></textarea>
                <div v-else class="add_jianli" onclick="go_edit()">该医生暂未填写擅长内容</div>
            </div>
        </div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
        getData()
        api.addEventListener({
            name: 'editUserInfo'
        }, function (ret, err) {
            getData()
        });

        // alert(JSON.stringify($api.getStorage("emp")))
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            info: "",
            avatar: ""
        },
        methods: {

        },

    })

    function getData() {
        // 请求个人信息数据
        get_ajax("doctor/verify/view", {
            userId: $api.getStorage("emp").userId,
        }, function (res, err) {
            // alert(JSON.stringify(res))
            if (res.data) {
                res.data["phone"] = $api.getStorage("emp").phone
                $api.setStorage("emp", res.data)
                api.sendEvent({
                    name: 'login',
                });
                app.info = res.data
                app.avatar = res.data.avatar ? IMAGE_HTTP + res.data.avatar : ""
            } else {
                app.info.name = "医生" + $api.getStorage("emp").userId
                app.sex = "请选择"
            }

        })
    }

    function go_edit() {
        api.openWin({
            name: "doctor_info_win",
            url: "widget://html/doctor/doctor_info_win.html",
            pageParam: {
                index: 1
            }
        })
    }
</script>
